package com.li.youhappygo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.li.youhappygo.model.dto.CategoryQueryParamDto;
import com.li.youhappygo.model.entity.commond.Category;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Mapper
public interface CategoryMapper extends BaseMapper<Category> {


    @Select("select category.* FROM (select * FROM category where (#{parentName} IS NULL or name LIKE #{parentName}  )) " +
            "as table1 left join category ON category.parent_id = table1.id where (#{name} IS NULL OR category.`name` LIKE #{name})")
    List<Category> selectByQueryParam(CategoryQueryParamDto categoryQueryParamDto);
}
